package com.nxcy.caculator;

import com.nxcy.caculator.oper.Operation;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import java.util.Scanner;

public class Caculator3 {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第一个操作数");
        double num1 = sc.nextInt();
        System.out.println("请输入操作符");
        String oper = sc.next();
        System.out.println("请输入第二个操作数");
        double num2 = sc.nextInt();
        double result = 0;
        Operation operation = null;
        Properties properties = new Properties();
        InputStream in = new FileInputStream(new File("/Users/zhli/工作空间/IDEA/ssm-study/ssm-spring/src/main/java/com/nxcy/caculator/cal3/oper.ini"));
        properties.load(in);
        final String className = properties.getProperty(oper);
        final Class operationClass = Class.forName(className);
        operation = (Operation) operationClass.newInstance();
        result = operation.caculate(num1, num2);
        System.out.println(num1 + oper + num2 + "=" + result);
    }
}
